﻿<?php
	include("pChart/pData.class");
	include("pChart/pChart.class");
	function createChar($dt1,$dt2,$dt3,$dt4,$mamon)
	{
		// Dataset definition 
		 $DataSet = new pData;
		 $DataSet->AddPoint($dt1,"Serie1");
		 $DataSet->AddPoint($dt2,"Serie2");
		 $DataSet->AddPoint($dt3,"Serie3");
		 $DataSet->AddPoint($dt4,"Serie4");
		 $DataSet->AddAllSeries();
		 $DataSet->SetAbsciseLabelSerie();
		 $DataSet->SetSerieName("Khong hai long","Serie1");
		 $DataSet->SetSerieName("Hai long","Serie2");
		 $DataSet->SetSerieName("Rat hai long","Serie3");
		 $DataSet->SetSerieName("Xuat sac","Serie4");
		
		 // Initialise the graph
		 $Test = new pChart(850,300);
		 $Test->setFontProperties("Fonts/times_1.ttf",8);
		 $Test->setGraphArea(50,30,680,250);
		 $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
		 $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
		 $Test->drawGraphArea(255,255,255,TRUE);
		 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);
		 $Test->drawGrid(4,TRUE,230,230,230,50);
		
		 // Draw the 0 line
		 $Test->setFontProperties("Fonts/times_1.ttf",6);
		 $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
		
		 // Draw the bar graph
		 $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,80);
		
		
		 // Finish the graph
		 $Test->setFontProperties("Fonts/times_1.ttf",13);
		 $Test->drawLegend(700,200,$DataSet->GetDataDescription(),255,255,255);
		 $Test->setFontProperties("Fonts/times_1.ttf",10);
		 $Test->drawTitle(50,22,$mamon,50,50,50,585);
		 $Test->Render("bieudo/image/".$mamon.".png");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
      $magv=$_REQUEST["ma"];
	  $hknk=$_REQUEST["hk"];
	  $tam=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk' ");
	  $t=mysql_fetch_row($tam);
	  $hk=$t[1];$nk=$t[2];
	  $cnk=$_SESSION['cnk']; 
        $sql=mysql_query("select * from khoa where username='$cnk'");
		$r=mysql_fetch_row($sql);
		$tenkhoa=$r[1];
		$makhoa=$r[0];
	  $tgv=mysql_query("select ten_gv from `giang vien` where ma_gv='$magv'");
	  $tgv1=mysql_fetch_row($tgv);
	  $tengv=$tgv1[0];
	  $k=mysql_query("select ma_sv from `danh gia` a,`lop hoc phan` b,`khoa` c,
	  `giang vien` d,`bo mon` e where  a.ma_hknk='$hknk' and a.ma_hp=b.ma_hp and a.stt_nhom=b.stt_nhom and a.ma_hknk=b.ma_hknk and c.ma_khoa=e.ma_khoa and d.ma_gv='$magv' and d.ma_bm=e.ma_bm and d.ma_gv=b.ma_gv group by a.ma_hp,a.stt_nhom,a.ma_hknk,ma_sv");
		while($k1=mysql_fetch_row($k))
		{
		       $ma=$k1[0];
			   $dem++;
		}
	  $tam=mysql_query("select sum(sisolop_hp) from `lop hoc phan` where ma_gv='$magv' and ma_hknk='$hknk' ");
	   $t=mysql_fetch_row($tam);
	   $ss=$t[0];
		
?>
<table align="center" >
           <tr>
		       <td align="center">
	        
                   <span class="style6" style="font-size:30px">
					KẾT QUẢ NHẬN XÉT TẤT CẢ MÔN HỌC <br />
					MSCB: <?php echo $magv; ?><br />
					Tên Cán Bộ: <?php echo $tengv; ?><br />
					Tổng Số Sinh Viên: <?php echo $ss; ?>
					
					</span>
				</td>
		  </tr>
		  <tr><td height="20">&nbsp;</td></tr>
					<form id="f" name="f" method="post" action="">	
        <tr> <td valign="top" bordercolor="#FFFFFF">
    	
          <table width="850" align="center" cellspacing="0" border="1" bordercolor="#0066FF" cellpadding="0">
       		
      		
                            
      		<tr align="center" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
            	<td width="413" height="40" class="bg"><span class="style7">Nội Dung Đánh Giá</span>				</td>
       	  	  	<td width="133" class="bg">
				          <span class="style7">Chưa Hài Lòng</span>				</td>
				<td width="112" class="bg">
				          <span class="style7">Hài Lòng</span>				</td>
				<td width="118" class="bg">
				          <span class="style7">Rất Hài Lòng</span>				</td>
				<td width="112" class="bg1">
				          <span class="style7">Xuất Sắc</span>				</td>
				
       	  	</tr>

		   <?php
		                $khl=array();
						$hl=array();
						$rhl=array();
						$xs=array();
		           
					
					    $sql=mysql_query("select a.ma_tc,a.noidung_tc from `tieu chi` a, `tieuchi hocki` b where a.ma_tc=b.ma_tc and b.ma_hknk='$hknk' ");
						
						while($row=mysql_fetch_row($sql))
						{
						   $matc=$row[0];
						   $noidung=$row[1];
						   $sql1=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hp in (select  distinct(c.ma_hp) from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and d.ma_gv='$magv') and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='1' group by `muc danh gia`,ma_tc");
						   $sql2=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hp in (select  distinct(c.ma_hp) from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and d.ma_gv='$magv') and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='2' group by `muc danh gia`,ma_tc");
						   $sql3=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hp in (select  distinct(c.ma_hp) from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and d.ma_gv='$magv') and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='3' group by `muc danh gia`,ma_tc");
						   $sql4=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hp in (select  distinct(c.ma_hp) from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and d.ma_gv='$magv') and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='4' group by `muc danh gia`,ma_tc");
						   if(mysql_num_rows($sql1)==0) $muc1=0;
						   else
						   {
						   $r1=mysql_fetch_row($sql1);
						   $muc1=$r1[2];
						   }
						   if(mysql_num_rows($sql2)==0) $muc2=0;
						   else
						   {
						   $r2=mysql_fetch_row($sql2);
						   $muc2=$r2[2];
						   }
						   if(mysql_num_rows($sql3)==0) $muc3=0;
						   else
						   {
						   $r3=mysql_fetch_row($sql3);
						   $muc3=$r3[2];
						   }
						   if(mysql_num_rows($sql4)==0) $muc4=0;
						   else
						   {
						   $r4=mysql_fetch_row($sql4);
						   $muc4=$r4[2];
						   }
						   ?>
						   <tr bordercolor="#FFFFFF">
						       <td class="bg" height="60" style="font-size:20px;">
							         <?php echo "&nbsp;&nbsp; $matc. $noidung"; ?> 
							   </td>
					
							   <td class="bg" align="center">
							        <?php
									      $t=($muc1/$dem)*100;
										  $t1=round($t,2);
										  $khl[]=$t1; 
										  echo " $t1 &nbsp;&nbsp; %";
										  
									?>
							   </td>
							   <td class="bg" align="center">
							       <?php
									       
										  $t=($muc2/$dem)*100;
										  $t1=round($t,2);
										  $hl[]=$t1; 
										  echo " $t1 &nbsp;&nbsp; %";
									?>
							   </td>
							   <td class="bg" align="center">
							          <?php
									      
										   $t=($muc3/$dem)*100;
										  $t1=round($t,2); 
										  $rhl[]=$t1;
										  echo " $t1 &nbsp;&nbsp; %";
									 ?>
							   </td>
							   <td class="bg1" align="center">
							          <?php
									       $t=($muc4/$dem)*100;
										  $t1=round($t,2);
										  $xs[]=$t1; 
										  echo " $t1 &nbsp;&nbsp; %";
										   
									?>
							   </td> 
							     
                           </tr>
						   <?php
						      
						}//while
						 
					 
		   ?>
		   
	 <tr bordercolor="#FFFFFF">
		    <td  colspan="5">
				<table width="100%">
				        
						 <tr><td height="20">&nbsp;</td></tr>
						
						 <tr>
							 <td  style="font-size:22px; font-weight:bold; color:#000099;">
							 * Ý Kiến Khác:
							 </td>
							 
						 </tr>
						 <tr>
						      <td style="font-size:20px; font-weight:bold">
							      <?php
								      $t=mysql_query("select ghi_chu from `hoc` where ma_hknk='$hknk' and ma_hp in (select  distinct(c.ma_hp) from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and d.ma_gv='$magv' )"); 
									   while ($t1=mysql_fetch_row($t))
									  {	  $t2=$t1[0];
										  if($t2=="") echo "";
										  else
										      echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $t2<br/>";
									  }
								  ?>
							  </td>
							  
						 </tr>
						 
						 <tr><td height="20">&nbsp;</td></tr>
						 
						<tr >
									<td width="98%" style="font-size:22px; font-weight:bold; color:#000099;">
										 * Biểu Đồ:
											 </td>
									
						</tr> 
						<tr>
										<td  style="font-weight:bold">
												  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(%)
										</td>
										
					   </tr>
					   <tr>
										 <td  align="center" >
											<!-- bieu do -->
											
											<?php
											
												createChar($khl,$hl,$rhl,$xs,$magv.$hknk);
												?>
											<img src="bieudo/image/<?php echo $magv.$hknk.".png"; ?>" />
											<!-- /bieu do -->
										</td>
		                      </tr>
							  <tr>
													
													<td style="font-weight:bold; font-size:16px" align="right" >
													 Tiêu Chí&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													</td>
						                   </tr> 
							  
							  <tr > <td height="50"  >
										<table width="100%"> <tr >
											<td width="98%" style="font-size:20px; font-weight:bold; color:#000099;" align="right" >
														 Số Lượng Sinh Viên Tham Gia Đánh Giá: <?php echo $dem; ?>
															 </td>
											<td width="2%" > </td>
										</tr> </table>
										</td> 
	                         </tr>
						
						<tr><td height="20">&nbsp;</td></tr>
						
						</table>
					</td> 
			 </tr>
					  
		       </table>
		  </td>
    </tr>
    
</form>
</table>
</body>
</html>
